package reflect;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

/**
 * Created by 5406160@qq.com on LiBoWen 李博闻.
 *
 * @ClassName : ClassTest
 * @Author : 54061
 * @Date: 2022/2/25 19:17
 */
public class ClassTest {
    public static void main(String[] args) throws NoSuchMethodException, InterruptedException, InvocationTargetException, InstantiationError, IllegalAccessException, InstantiationException {
        //获取student的Class对象
        Class<Student> clazz = Student.class;
        //获取class所对应类型中的无参构造器
        Constructor<Student> constructor = clazz.getConstructor();
        //通过构造器对象实例化对象
        Student student = constructor.newInstance();
        System.out.println("student = " + student);
    }
}
